import org.junit.Test;
import junit.framework.Assert;



public class TestTransactionList 
{
	@Test
	public void testTransactionListConstructor()
	{
		TransactionList tl = new TransactionList();
		
		Assert.assertEquals(tl.size(), 0);
	}
	
	@Test
	public void testAddTransaction() throws Exception
	{
		TransactionList tl = new TransactionList();
		tl.addTransaction("tests\\testTransaction.out");
		
		Assert.assertEquals(tl.firstElement(), new Transaction(Transaction.Code.CREATE, "Sample", DVD.Status.RENTAL, 1, 0));
	}
	
	@Test
	public void testAddTransactionShortRecord() throws Exception
	{
		TransactionList tl = new TransactionList();
		boolean exception = false;
		try
		{
			tl.addTransaction("tests\\testTransactionArrayIndexOutOfBounds.out");
		}
		catch (FatalErrorException ex)
		{
			exception = true;
		}
		
		Assert.assertTrue (exception);
	}
	
	@Test
	public void testAddTransactionNumberFormat() throws Exception
	{
		TransactionList tl = new TransactionList();
		boolean exception = false;
		try
		{
			tl.addTransaction("tests\\testTransactionNumberFormat.out");
		}
		catch (FatalErrorException ex)
		{
			exception = true;
		}
		
		Assert.assertTrue (exception);
	}
	
	@Test
	public void testAddTransactionEmpty() throws Exception
	{
		TransactionList tl = new TransactionList();
		boolean exception = false;
		try
		{
			tl.addTransaction("tests\\testTransactionEmpty.out");
		}
		catch (FatalErrorException ex)
		{
			exception = true;
		}
		
		Assert.assertTrue (exception);
	}
		
}
